//import  ApplicationContext from '../ApplicationContext'
import Jsr from "../../jsr/Jsr.js";
export default function Resource(...list) {
    return function (target) {
        let obj= qguan(target.name);
        if(!obj){
            obj=   new target();
            qguan(target.name,obj,'','save')
        }

        if(obj.inlet){
            let jsrName=list[0];
            let className=list[2];

            let root= qguan("root")
            let data=root.findData(jsrName+".jsr")

            data.then((data1)=>{
                let jsr =new Jsr();
                jsr.loadData(data1)
                let aopFactory=qguan("aopFactory")
                let code=  jsr.findFileByRegular(jsrName,"",className);
                if(code){
                    let tes1=new TextDecoder();
                    let buff=new Uint8Array(code);
                    let txt= tes1.decode(buff);
                    let resObj=     aopFactory.createCodeObj(jsrName,className,txt);
                    resObj.then((shili)=>{
                        let obj1= qguan(target.name);
                        obj1.inlet(jsrName,'',className,shili.default);
                        qguan(target.name,obj1,'','save')

                    })

                }

            })
        }



    }
}